<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>用户添加</title>

    <base href="/">

    <link rel="shortcut icon" th:href="@{assets/media/image/favicon.png}"/>
    <link rel="stylesheet" th:href="@{vendors/bundle.css}" type="text/css">
    <link rel="stylesheet" th:href="@{vendors/datepicker/daterangepicker.css}">
    <link rel="stylesheet" th:href="@{vendors/vmap/jqvmap.min.css}">
    <link rel="stylesheet" th:href="@{assets/css/app.css}" type="text/css">
    <!--弹窗CSS-->
    <link rel="stylesheet" th:href="@{/assets/css/modal.css}" type="text/css">
</head>
<body class="container">

<div class="preloader">
    <div class="preloader-icon"></div>
</div>

<!--引入公共头部页面-->
<div th:replace="~{commons/header :: header}"></div>

<div id="main">
    <!--引入公共导航栏页面-->
    <div th:replace="~{commons/navigation :: navigation}"></div>

    <!-- begin::主要内容 -->
    <div class="main-content">
        <div class="row">
            <div th:if="${errormessage} ne null" style="width: 400px;" class="alert alert-danger"
                 role="alert" >[[${errormessage}]]
            </div>
            <div class="col-md-10 card" style="margin-left: 15px">
                <form action="/user/adduser" method="post">
                    <div class="form-row">
                        <div class="form-group">
                            <label for="exampleInputEmail1"><br>密码默认为：123456</label>
                            <input type="password" readonly name="pwd" class="form-control" style="width:250px;"  value="123456" >
                        </div>
                        <!--                                </fieldset>-->
                        <div class="form-group">
                            <label for="exampleInputPassword1"><br>用户名:</label>
                            <input style="width:250px;" class="form-control" name="username" id="exampleInputPassword1"
                                   placeholder="输入用户名">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputEmail1">姓 名:</label>
                            <input name="name" class="form-control" style="width:250px;"  placeholder="输入姓名" >
                        </div>
                        <div class="form-group">
                            <label for="exampleInputEmail1">地 址:</label>
                            <input name="addr" class="form-control" style="width:250px;"  placeholder="输入地址" >
                        </div>
                        <div class="form-group">
                            <label for="exampleInputEmail1">邮 箱</label>
                            <input type="email" name="email" class="form-control" style="width:250px;" id="exampleInputEmail1"
                                   aria-describedby="emailHelp" placeholder="输入邮箱">
                        </div>

                        <div class="form-group">
                            <label for="exampleInputEmail1">手机号:</label>
                            <input name="phone" class="form-control" style="width:250px;"  placeholder="输入手机号码" >
                        </div>
                        <div class="form-group">
                            <label for="company">公 司：</label>
                            <select name="companyId" class="form-control" style="width:250px;"  id="company">
                                <option disabled>请选择...</option>
                                <option th:each="company:${companies}" th:value="${company.companyId}" th:text="${company.companyName}">One</option>
                            </select>
                        </div>
                        <!--<div class="form-group" >
                            <label for="role2">公 司:</label>
                            <select class="form-control"  id="role2" name="companyId" style="width:550px;" >
                                <option value="0">华北强公司</option>
                                <option value="1">华南强公司</option>
                                <option value="2">捡破烂有限公司</option>
                                <option value="3">无限有限公司</option>
                                <option value="4">五虎上将有限公司</option>
                            </select>
                        </div>-->
                        <div class="form-group" >
                            <label for="role1">角 色:</label>
                            <select class="form-control"  id="role1" name="role" style="width:250px;" >
                                <option selected value="0">分公司管理员</option>
                                <option value="1">燃料业务员</option>
                                <option value="2">监察员</option>
                                <option value="3">管理员</option>
                                <option value="4">公告通知发布人员</option>
                            </select>
                        </div>

                        <div class="form-group">
                            <label for="exampleFormControlSelect1">部 门:</label>
                            <select class="form-control" style="width:250px;" name="departmentId" id="exampleFormControlSelect1">
                                <option selected value="1">分公司管理部</option>
                                <option value="2">燃料业务部</option>
                                <option value="3">监察部</option>
                                <option value="4">管理部</option>
                                <option value="5">公告通知部</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="exampleFormControlSelect2">状 态：</label>
                            <select class="form-control" style="width:250px;" name="del" id="exampleFormControlSelect2">
                                <option selected value="0">正常</option>
                                <option value="1">注销</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-sm-4 text-right">
                            <button type="submit" class="btn btn-primary"  style="border-radius: .30em;">添 加</button>
                        </div>
                        <div class="col-sm-3 text-right">
<!--                            th:href="${#request.getHeader('Referer')}"-->
                            <a href="/user/query" type="button" class="btn btn-gradient-dark"  style="border-radius: .30em;">取 消</a>
                        </div>
                    </div>
                </form>
                <!--<form id="form-add-user" action="/user/info_modify" method="post" style="margin-top: 50px;margin-bottom: 50px;font-size: 115%">
                    <input name="id" value="0" type="hidden">

                    <div class="form-group row">
                        <label for="company" class="col-sm-4 col-form-label text-right">单位</label>
                        <select name="companyId" class="col-sm-3 form-control" id="company" style="border-radius: .30em;">
                            <option disabled>请选择...</option>
                            <option th:each="company:${companies}" th:value="${company.companyId}" th:text="${company.companyName}">One</option>
                        </select>
                    </div>

                    <div class="form-group row">
                        <label for="department" class="col-sm-4 col-form-label text-right">部门</label>
                        <select name="departmentId" class="col-sm-3 form-control" id="department"  style="border-radius: .30em;">
                            <option disabled>请选择...</option>
                            <option th:each="department:${departments}" th:value="${department.departmentId}" th:text="${department.departmentName}" value="1">One</option>
                        </select>
                    </div>

                    <div class="form-group row">
                        <label for="uname" class="col-sm-4 col-form-label text-right">用户名</label>
                        <div>
                            <input name="username" type="text" class="form-control" id="uname" style="border-radius: .30em;">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="password" class="col-sm-4 col-form-label text-right">密码</label>
                        <div>
                            <input name="pwd" type="password" class="form-control" id="password"  style="border-radius: .30em;">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="name" class="col-sm-4 col-form-label text-right">姓名</label>
                        <div>
                            <input name="name" id="name" type="text" class="form-control"  style="border-radius: .30em;">
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="phone" class="col-sm-4 col-form-label text-right">联系方式</label>
                        <div>
                            <input name="phone" type="text" class="form-control" id="phone"  style="border-radius: .30em;">
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="role" class="col-sm-4 col-form-label text-right">角色</label>
                        <select name="role" class="col-sm-3 form-control" id="role" style="border-radius: .30em;">
                            <option disabled>请选择...</option>
                            <option value="0">分公司管理员</option>
                            <option value="1">燃料业务人员</option>
                            <option value="2">监察人员</option>
                            <option value="3">管理人员</option>
                            <option value="4">公告通知发布人员</option>
                        </select>
                    </div>

                    <div class="form-group row">
                        <div class="col-sm-5 text-right">
                            <button type="submit" class="btn btn-primary"  style="border-radius: .30em;">添加</button>
                        </div>
                        <div class="col-sm-3 text-right">
                            <a th:href="${#request.getHeader('Referer')}" type="button" class="btn btn-gradient-dark"  style="border-radius: .30em;">取消</a>
                        </div>
                    </div>
                </form>-->
            </div>
        </div>

        <!--引入公共的JavaScript脚本-->
        <div th:replace="~{commons/footer :: footer}"></div>
    </div>
</div>
<!--引入公共的JavaScript脚本-->
<div th:include="~{commons/scripts :: scripts}"></div>
<script src="assets/js/app.js"></script>
<script src="assets/js/modal.js"></script>
<script th:inline="javascript">
    $(() => {
        $('#form-add-user').submit(function () {
            let data = $(this).serializeArray();
            let url = "/user/add"
            $.post(url, data, function (data) {
                let method = function () {}
                if (data.code >= 0) {
                    method = function () {
                        window.location.href = /*[[${#request.getHeader('Referer')}]]*/"/user/query"
                    }
                }
                let mModal1 = new mModal({
                    title: "提示", // 标题，默认：提示
                    width: "25%", // 弹出框宽度，默认 25%
                    top: "25vh", // 距离可视区域顶部距离 CSS中 margin-top 值
                    content: data.msg, // 正文，默认：正文内容
                    cancelText: "取 消", // 取消按钮文本
                    confirmText: "确 定", // 确定按钮文本
                    showCancelButton: false, // 是否显示取消按钮
                    showConfirmButton: true, // 是否显示确定按钮
                    showClose: true, // 是否显示关闭按钮
                    modal: true, // 是否需要遮罩层
                    customClass: "", // 自定义类名confirm
                    confirm: function () {
                        mModal1.close();
                        method();
                    },
                });
                mModal1.renderDom();
            }, "json")
            return false;
        })
    })
</script>
</body>
</html>
